import request from '@/utils/request'

// 角色列表
export function reqRoleList(page: number) {
  return request({
    url: `/admin/role/${page}`,
    method: 'get'
  })
}

// 删除
export function reqDeleteRole(id: number) {
  return request({
    url: `/admin/role/${id}/delete`,
    method: 'post'
  })
}

// 新增
export function reqAddRole(data: { name: string; desc: string; status: number }) {
  return request({
    url: '/admin/role',
    method: 'post',
    data
  })
}

// 修改
export function reqUpdateRole(id: number, data: { name: string; desc: string; status: number }) {
  return request({
    url: `/admin/role/${id}`,
    method: 'post',
    data
  })
}

// 修改状态
export function reqUpdateRoleStatus(id: number, status: number) {
  return request({
    url: `/admin/role/${id}/update_status`,
    method: 'post',
    data: {
      status
    }
  })
}

// 配置角色权限
export function reqConfigRole(id: number, rule_ids: number[]) {
  return request({
    url: `/admin/role/set_rules`,
    method: 'post',
    data: { id, rule_ids }
  })
}
